package com.itheimamobileguard.activitys;

import com.example.mobile.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;

public class Setup4Activity extends BaseSetUpActivity {
	
	private TextView tv_setup_status;
	private CheckBox cb_project;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setup4);
		tv_setup_status = (TextView) findViewById(R.id.tv_setup_status);
		cb_project = (CheckBox) findViewById(R.id.cb_project);
		cb_project.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if (isChecked) {
					tv_setup_status.setText("防盗保护已经开启");
				}else{
					tv_setup_status.setText("防盗保护未开启");
				}
				Editor editor =sp.edit();
				editor.putBoolean("protecting", isChecked);
				editor.commit();
			}
		});
		
		boolean protecting = sp.getBoolean("protecting", false);
		if (protecting) {
			tv_setup_status.setText("防盗保护已经开启");
			cb_project.setChecked(true);
		}else{
			cb_project.setChecked(false);
			tv_setup_status.setText("防盗保护未开启");
		}
	}

	public void showNext() {
		// 写一个配置信息
		Editor editor = sp.edit();
		editor.putBoolean("finishSet", true);
		editor.commit();
		startAndFinshActivity(LostFindActivity.class);
	}


	@Override
	public void showPre() {
		startAndFinshActivity(Setup3Activity.class);		
	}

}
